<?php

!defined('DEBUG') AND exit('Access Denied.');

$i = param(1);

error_reporting(E_ALL);

if($i=='vcode'){
	$checkCode = "0,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
	$checkCode = explode(',',$checkCode);
	shuffle($checkCode);
	$checkCode = $checkCode[0].$checkCode[1].$checkCode[2].$checkCode[3];
	
	//发送头文件
	header("content-type: image/png");
	//创建图像
	$im = imagecreatetruecolor(90, 30);
	//定义颜色
	$white = imagecolorallocate($im,255,255,255);
	$grey = imagecolorallocate($im,228,228,228);
	$black = imagecolorallocate($im,0,0,0);
	imagefilledrectangle($im, 0, 0, 399, 29, $white);
	//这里是字体文件的路径
	$font = APP_PATH.'view/font/Elephant.ttf';
	//为文字添加阴影，即为灰色画出文本
	imagettftext($im,20,0,13,23,$grey,$font,$checkCode);
	//添加文本，即用黑色画出文本
	imagettftext($im,20,0,2,20,$black,$font,$checkCode);
	//输出png图像
	imagepng($im);
	imagedestroy($im);
	setcookie('vcode', $checkCode, $time+300);
}else if($i=='pay_png'){
	$url = urldecode(param('url'));
	echo createQrCode($url);
}else if($i=='auto_clear'){
	//计划任务 每天0点自动清0商户累积收款金额和通道累积收款金额
	$now=date('Hi');
	if($now>3) die('非执行时间');
	db_update('user', array(), array('tj_pay' => 0));//清0商户累积收款金额
	db_update('channel', array(), array('money_total' => 0));//清0通道累积收款金额
	die('清0成功');
}else{
	$notice = db_find('article', array('cid'=>1), array('time'=>'-1'));
	$news = db_find('article', array('cid'=>2), array('time'=>'-1'));
	if($user) header("Location:".url('user-center'));
	else header("Location:".url('user-login'));
	include show_tpl('index.htm');
}




?>